# Contributor: John Regan <john@jrjrtech.com>
# Maintainer: Laurent Bercot <ska-devel@skarnet.org>
pkgname=skalibs
# NOTE: If you're upgrading to a new version that fixes some security
# vulnerability in the APIs used by utmps (mainly timed ipcs),
# rebuild the following aports:
# - busybox
# - mingetty
# - openssh
# - util-linux
pkgver=2.14.1.1
pkgrel=0
pkgdesc="Set of general-purpose C programming libraries for skarnet.org software."
url=https://skarnet.org/software/skalibs/
arch="all"
license="ISC"
options="!check"
subpackages="$pkgname-static $pkgname-dev $pkgname-doc"
source="https://skarnet.org/software/skalibs/skalibs-$pkgver.tar.gz skalibs.pc"

prepare() {
	default_prepare
	sed -i "s|@@VERSION@@|$pkgver|" -i "$srcdir"/*.pc
}

build() {
	./configure \
		--enable-shared \
		--enable-static \
		--libdir=/usr/lib
	make
}

package() {
	make DESTDIR="$pkgdir" install
	install -D -m 0644 "$srcdir/skalibs.pc" "$pkgdir/usr/lib/pkgconfig/skalibs.pc"
	mkdir -p "$pkgdir/usr/share/doc"
	cp -a "$builddir/doc" "$pkgdir/usr/share/doc/$pkgname"
}

dev() {
	default_dev
	mkdir -p "$subpkgdir"/usr/lib/"$pkgname"/sysdeps
	mv "$pkgdir/usr/lib/$pkgname"/sysdeps/* \
		"$subpkgdir/usr/lib/$pkgname"/sysdeps
	rm -rf "$pkgdir/usr/lib"
}

sha512sums="
01b3da7614ee626f838b62aff6fa2d4677ab5c5dfffcb3145232db9ac0b5bf70c063f4d83abdee809139fee721c75550eb997e2c3e265417b9493c98886236f9  skalibs-2.14.1.1.tar.gz
5771f0e72e7e7e9a45cafdf2e4508938a29ff9474845c897e383004b031ad142dee1b65d83a9a0168696782163cb4a32f82db4d7360413b433e68282cd4cc487  skalibs.pc
"
